using Microsoft.Win32;
using System.Configuration;
namespace PIM.Utilities.ConfigurationStore
{
	public class QSecureRegistry
	{
		// This is Initial Directory setting for registry.		
		private const string _safeKeyPath = @"Software\Quantum Secure\Safe";
        //private const string _safeKeyPath64 = @"SOFTWARE\WOW6432NODE\Quantum Secure\Safe";
		
		public static string GetStringValue(string keyPath, string valueName)
		{
			try
			{
				using (RegistryKey key = Registry.LocalMachine.OpenSubKey(keyPath))
				{
					if (key != null)
						return key.GetValue(valueName, string.Empty).ToString();
				}			
			}
			catch
			{
			}
			return string.Empty;
		}

		public static string GetConfigFilePath()
		{
            string s = "";
            //string s = System.Configuration.ConfigurationManager.AppSettings["ConfigXMLPath"];
            if (string.IsNullOrEmpty(s))
            {
                return GetStringValue(_safeKeyPath, "ConfigXMLPath");
            }
            else
            {
                string path = System.IO.Path.GetFullPath(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, s));
                return path;
            }
		}
	}
}
